package com.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.base.BaseAction;
import com.domain.Role;
import com.service.RoleService;

@Controller(value="roleAction")
@Scope("prototype")
public class RoleAction extends BaseAction<Role> {
	@Resource(name="roleService")
	private RoleService roleService;
	
	/**
	 * 查新所有的角色
	 * @return
	 */
	public String findAllRole(){
		List<Role> roleList=roleService.findAllRole();
		this.writeList2json(roleList, new String[]{"users","functions"});
		return NONE;
	}
	/**
	 * 保存添加的角色
	 * @return
	 */
	private String functionIds;
	public void setFunctionIds(String functionIds) {
		this.functionIds = functionIds;
	}

	public String saveRole(){
		System.out.println(functionIds);
		roleService.saveRole(model,functionIds);
		return SUCCESS;
	}
}
